using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;

namespace Ling.ZhControls
{
	/// <summary>
	///  Fade form, we use this while fade effect . ..
	/// </summary>
	internal class FadeForm : System.Windows.Forms.Form
	{
		TabDrawMode drawMode = TabDrawMode.Normal;
		LinearGradientBrush _Brush = null;

		public FadeForm()
		{
			SetStyle (ControlStyles.DoubleBuffer, true);
			TopLevel = true;
			TopMost = true;
			ShowInTaskbar = false;
			FormBorderStyle = FormBorderStyle.None;
			Visible = false;

			SetWindowPos(Handle, 0, Location.X, Location.Y, 
				Width, Height,
				SWP_NOACTIVATE);
		}

		[DllImport("user32.dll")]
		public static extern bool SetWindowPos(IntPtr hWnd, int hWndAfter, 
			int x, int y, int width, int height, int flags);

		public const int SWP_NOACTIVATE      = 0x0010;

		public new void Show ()
		{
			StaticPaint.ShowWindow (Handle, 4); // do not got focus ...
		}

		protected override void OnPaintBackground(PaintEventArgs pevent)
		{
			if (drawMode == TabDrawMode.Normal)
				base.OnPaintBackground(pevent);
			else
			{
				pevent.Graphics.FillRectangle(Brush,
					ClientRectangle);
			}
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}

		public TabDrawMode DrawMode
		{
			get {return drawMode;}
			set {drawMode = value;}
		}

		public LinearGradientBrush Brush
		{
			get {return _Brush;}
			set {_Brush = value;}
		}
	}
}
